package com.ruoyi.hbs.service;

import com.ruoyi.hbs.domain.HbsBusinessMapping;
import com.ruoyi.hbs.domain.HbsProductMapping;
import com.ruoyi.hbs.domain.HbsTerminalMapping;
import com.ruoyi.hbs.domain.SingleSalesInventoryRecords;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 简化药品销售与库存记录表Service
 */
public interface SingleSalesInventoryRecordsService extends IService<SingleSalesInventoryRecords> {


    /**
     * 同步导入
     */
    void syncImport();

    /**
     * 处理终端首单记录
     */
    @Transactional(rollbackFor = Exception.class)
    void msfxProcessTerminalFirstOrder();

    /**
     * 处理未匹配的记录
     */
    @Transactional(rollbackFor = Exception.class)
    void processUnmatchedRecords();

    /**
     * 聚合补充处理未匹配的记录
     */
    @Transactional(rollbackFor = Exception.class)
    void processUnmatchedRecordes();

    /**
     * 产品匹配
     */
    @Transactional(rollbackFor = Exception.class)
    boolean matchAndSaveProduct(List<HbsProductMapping> mappingsProductToInsert,
                                List<HbsProductMapping> empProductToInsert, SingleSalesInventoryRecords record);

    /**
     * 商业匹配
     */
    @Transactional(rollbackFor = Exception.class)
    boolean matchAndSaveBusiness(List<HbsBusinessMapping> mappingsBussinessToInsert,
                                 List<HbsBusinessMapping> empBussinessToInsert, SingleSalesInventoryRecords record);

    /**
     * 终端匹配
     */
    @Transactional(rollbackFor = Exception.class)
    boolean matchAndSaveTerminal(List<HbsTerminalMapping> mappingsTerminalToInsert, List<HbsTerminalMapping> empTerminalToInser, SingleSalesInventoryRecords record);

    /**
     * 删除重复记录
     */
    @Transactional(rollbackFor = Exception.class)
    void deleRepeat();
}
